package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Userprojcet;
import com.ruoyi.system.service.IUserprojcetService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 注册表与用户的关联Controller
 * 
 * @author zhh
 * @date 2024-07-11
 */
@RestController
@RequestMapping("/system/userprojcet")
public class UserprojcetController extends BaseController
{
    @Autowired
    private IUserprojcetService userprojcetService;

    /**
     * 查询注册表与用户的关联列表
     */
//    @PreAuthorize("@ss.hasPermi('system:userprojcet:list')")
    @GetMapping("/list")
    public TableDataInfo list(Userprojcet userprojcet)
    {
        startPage();
        List<Userprojcet> list = userprojcetService.selectUserprojcetList(userprojcet);
        return getDataTable(list);
    }

    /**
     * 导出注册表与用户的关联列表
     */
//    @PreAuthorize("@ss.hasPermi('system:userprojcet:export')")
    @Log(title = "注册表与用户的关联", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Userprojcet userprojcet)
    {
        List<Userprojcet> list = userprojcetService.selectUserprojcetList(userprojcet);
        ExcelUtil<Userprojcet> util = new ExcelUtil<Userprojcet>(Userprojcet.class);
        util.exportExcel(response, list, "注册表与用户的关联数据");
    }

    /**
     * 获取注册表与用户的关联详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:userprojcet:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(userprojcetService.selectUserprojcetById(id));
    }

    /**
     * 新增注册表与用户的关联
     */
//    @PreAuthorize("@ss.hasPermi('system:userprojcet:add')")
    @Log(title = "注册表与用户的关联", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Userprojcet userprojcet)
    {
        return toAjax(userprojcetService.insertUserprojcet(userprojcet));
    }

    /**
     * 修改注册表与用户的关联
     */
//    @PreAuthorize("@ss.hasPermi('system:userprojcet:edit')")
    @Log(title = "注册表与用户的关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Userprojcet userprojcet)
    {
        return toAjax(userprojcetService.updateUserprojcet(userprojcet));
    }

    /**
     * 删除注册表与用户的关联
     */
//    @PreAuthorize("@ss.hasPermi('system:userprojcet:remove')")
    @Log(title = "注册表与用户的关联", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(userprojcetService.deleteUserprojcetByIds(ids));
    }
}
